﻿'Params
'user (Required) : The user whose library you want to fetch.
'limit (Optional) : The number of results to fetch per page. Defaults to 50.
'page (Optional) : The page number you wish to scan to.
'api_key (Required) : A Last.fm API key.
'Auth
'This service does not require authentication. 

Public Structure LibraryGetArtistsResponse
    Public artists() As Artist
End Structure

Public Class LibraryGetArtists
	Inherits BaseRequest
    Dim user As String = ""
    Dim page As String = ""
    Dim limit As String = ""

	Public xmlresponse As XDocument = Nothing

    Public Sub New(user As String, page As String, limit As String)
        Me.user = user
        Me.page = page
        Me.limit = limit
    End Sub

	Public Sub sendRequest()
        InitializeMembers("library.getArtists")

        AddMember("user", user, True)
        AddMember("page", page, False)
        AddMember("limit", limit, False)

        AddMember("api_key", My.Settings.api_key, False)

        xmlresponse = sendPOSTResponse()
	End Sub

    Public Function getResponse() As LibraryGetArtistsResponse
        Dim response As New LibraryGetArtistsResponse
        Dim count As Integer

        Try
            count = xmlresponse.<lfm>.<results>.<artists>.Count()
        Catch ex As Exception
            Return response
        End Try

        If (count > 0) Then
            ReDim response.artists(count - 1)
            For i As Integer = 0 To count - 1
                response.artists(i) = New Artist(xmlresponse.<lfm>.<results>.<artists>(i))
            Next
        End If

        Return response
    End Function
End Class
